-- Sort a list of list based on list length.

import Data.List

-- Naive version.
compareListsByLength :: [a] -> [a] -> Ordering
compareListsByLength as bs
    | las < lbs = LT
    | las > lbs = GT
    | otherwise = EQ
    where las = length as
          lbs = length bs

-- Exercise 6.
sortList xs = sortBy compareListsByLength xs
